package com.xoa.controller.emergency;

import com.xoa.model.emergency.CrashDispatchParentWithBLOBs;
import com.xoa.service.emergency.CrashDispatchParentService;
import com.xoa.util.LimsDataTree;
import com.xoa.util.LimsJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("crashParent")
public class CrashDispatchParentController {
    @Autowired
    CrashDispatchParentService crashDispatchParentService;

    // 添加救援事件
    @RequestMapping("add")
    @ResponseBody
    public LimsJson add(HttpServletRequest request,CrashDispatchParentWithBLOBs crashDispatchParentWithBLOBs){
        return crashDispatchParentService.insert(request,crashDispatchParentWithBLOBs);
    }

    /**
     * 查询所有救援事件(不分页)
     * @return
     */
    @RequestMapping("selectAll")
    @ResponseBody
    public LimsJson showAll(){
        return crashDispatchParentService.queryAll();
    }

    /**
     * 查询所有救援事件
     * @param page
     * @param limit
     * @return
     */
    @RequestMapping("showAll")
    @ResponseBody
    public LimsJson showAll(Integer page,Integer limit){
        return crashDispatchParentService.queryAll(page,limit);
    }


    /**
     * 查询所有救援事件树
     * @return
     */
    @RequestMapping("showAllTree")
    @ResponseBody
    public List<LimsDataTree> showAllTree(){
        return crashDispatchParentService.queryAllTree();
    }


    /**
     * 查询救援事件下所有的任务
     * @return
     */
    @RequestMapping("showCrashDispById")
    @ResponseBody
    public LimsJson showCrashDispById(Integer crasPareId){
        return crashDispatchParentService.showCrashDispById(crasPareId);
    }

}
